<template>
	<view class="mainpadding2">
		<u-tabs :list="list1" lineColor="#F76D1A" :scrollable="false" @click="changetab" :activeStyle="{
			    color: '#F76D1A',
			    fontWeight: 'bold',
			    transform: 'scale(1.05)'
			}" :inactiveStyle="{
			            color: '#000000',
						fontWeight: 'bold',
			            transform: 'scale(1)'
			        }" itemStyle="height: 44px;"></u-tabs>
		<view class="" style="padding-bottom: 140rpx;" v-if="tabsid==1">
			<view class="ffffff radius mainpadding margin_top" v-for="item in list.data" :key="item.id"  @click="tzckshzt(item)">
				<view class="flexbetween">
					<view class="ershiba zhonghei fonweight">{{item.shop_name}}</view>
					<view class="" >
						<view class="strongtext xiaocheng fonweight" v-if="item.status==1">待审核</view>
						<view class="strongtext xiaohong fonweight" v-if="item.status==3">已拒绝</view>
						<view class="strongtext xiaolv fonweight" v-if="item.status==2">已通过</view>
					</view>
				</view>
				<view class="strongtext xiaohei margin_top">上传时间：{{item.createtime_text}}</view>
				<view class="shx margin_top" v-if="item.status==3 && item.sh_bz">
					<view class="strongtext xiaohong">拒绝理由：{{item.sh_bz}}</view>
				</view>
				<view class="flexbetween margin_top"  v-if="item.status==2 || item.status==3">
					<view class="strongtext xiaohei ">审核时间：{{item.sh_time_text}}</view>
					<!-- <view class="xhbtn flexcenter" v-if="item.status==2"  @click.stop="tzflmd ">管理门店</view> -->
					<view class="xhuibtn flexcenter" v-if="item.status==3"  @click.stop="tzsjrz(item.id)">重新申请</view>
				</view>
			</view>
		</view>
		<view class="" style="padding-bottom: 140rpx;" v-if="tabsid==2">
			<view class="ffffff radius mainpadding margin_top" v-for="item in list.data" :key="item.id">
				<view class="flexleft">
					<image :src="item.shop.logo_text" style="width: 100rpx;height: 100rpx;border-radius: 50%;margin-right: 30rpx;" mode=""></image>
					<view class="ershiba zhonghei fonweight xiankuan" style="width: 450rpx;">{{item.shop.name}}</view>
				</view>
				<view class="strongtext xiaohei margin_top">营业时间：{{item.shop.yysj}}</view>
				<!-- 通过状态 -->
				<view class="flexright margin_top" @click.stop="tzflmd(item.shop.id)">
					<!-- <view class="strongtext xiaohei ">通过时间：2023-06-29 10:40</view> -->
					<view class="xhbtn flexcenter">管理门店</view>
				</view>
			</view>
		</view>
		<view class="gudingdb mainpadding ffffff" @click="tzsjrztext">
			<view class="bigbtn">商家入驻</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				list1: [{
						name: '我入住的商家',
						value: 1,
					},
					{
						name: '我管理的门店',
						value: 2,
					}
				],
				tabsid: 1,
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.page = 1
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				let url = "/api/shopcl/myShopApply"
				if(this.tabsid==2){
					url = "/api/shopcl/myShopUserIndex"
				}
				httpRequest.request(url, 'GET', {
					page: page || 1,
					limit: _this.limit
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			changetab(e) {
				this.tabsid = e.value
				this.page = 1
				this.list = {
					data:[]
				}
				this.init()
			},
			// 跳转管理门店
			tzflmd(id) {
				uni.navigateTo({
					url: '/pages_wode/wodedianpu?id='+id
				})
			},
			// 跳转查看审核状态
			tzckshzt(item) {
				uni.navigateTo({
					url: '/pages_wode/shangjiarzsh?msg='+encodeURIComponent(JSON.stringify(item))
				})
			},
			// 跳转商家入驻
			tzsjrz(id) {
				uni.navigateTo({
					url: '/pages_wode/shangjiruzhu?id='+id
				})
			},
			tzsjrztext(){
				uni.navigateTo({
					url: '/pages_wode/shangjiruzhu'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xhbtn {
		width: 156rpx;
		height: 61rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		border: 2rpx solid #FF9341;
		background-color: #fff5ec;
		color: #FF9341;
	}
	.xhuibtn {
		width: 156rpx;
		height: 61rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		border: 2rpx solid #ff0000;
		background-color: rgba(255, 0, 0,.06);
		color: #ff0000;
	}

	.shx {
		padding-top: 30rpx;
		border-top: 1rpx solid #999999;
	}
</style>